/**
 * Boids Algorithm
 * All Right Reserved
 * Aug 1, 2011
 */
package com.huniu.internal.action;

import org.apache.struts2.ServletActionContext;

import com.huniu.links.ILinkSeedProcess;
import com.huniu.links.exception.LinkProcessException;

/**
 * @author chenheng
 * 
 */
public class LinkSeedAction extends BaseAction {

	private static final long serialVersionUID = -7846944336410502078L;
	
	private ILinkSeedProcess linkSeedProcess = null ;
	private String urls = null ;
	public void setLinkSeedProcess(ILinkSeedProcess linkSeedProcess) {
		this.linkSeedProcess = linkSeedProcess;
	}

	public String getUrls() {
		return urls;
	}

	public void setUrls(String urls) {
		this.urls = urls;
	}

	public String prepareSeed() {
		String seedsFolder = ServletActionContext.getServletContext().getRealPath("seeds");
		try {
			linkSeedProcess.generateSeedFile(seedsFolder, urls);
			return SUCCESS;
		} catch (LinkProcessException e) {
			this.addFieldError(urls, e.getMessage());
			return INPUT;
		}
	}

}
